import request from "../utils/request";


export const userLogin = (id, password) => {
    const params = new URLSearchParams()
    params.append('roomNumber', id)
    params.append('password', password)
    return request.put("/user/login", params)
}

export const findUser = (roomNumber) => {
    const params = new URLSearchParams()
    params.append("roomNumber", roomNumber)
    return request.get("/user/findByRoomNumber", params)
}

//新增业主
export const addUserService = (addUserData) => {
    const params = new URLSearchParams()
    for (let key in addUserData) {
        params.append(key, addUserData[key])
    }
    return request.post("/user/addUser", params)
}

//返回业主列表
// export const getAllUserService = (pageNum,pageSize) => {
//     const params = new URLSearchParams()
//     params.append("pageNum", pageNum)
//     params.append("pageSize", pageSize)
//     console.log(pageNum)
//     console.log(pageSize)
//     return request.get("/user/getAllUser", params)
// }

export const getAllUserService = (pageNum,pageSize) => {
    // const params = new URLSearchParams()
    // params.append('pageNum', pageNum)
    // params.append('pageSize', pageSize)
    // console.log()
    const params={'pageNum':pageNum,'pageSize':pageSize}
    return request.get("/user/getAllUser", {params:params})
}

//删除业主
export const deleteUserService = (roomNumber) => {
    // console.log('------------------' + roomNumber)
    const params = new URLSearchParams()
    params.append("roomNumber", roomNumber)
    return request.put('/user/deleteUser', params)
}

export const updateUserService = (updateUserDate) => {
    const params = new URLSearchParams()
    for (let key in updateUserDate) {
        params.append(key, updateUserDate[key])
    }
    return request.put("/user/updateUser", params)
}